test(integration): add PostgreSQL 14-18 compatibility matrix#150
Merged
Conversation
c3d9c72 to
b75ba24
Compare
Deploy 5 versioned PostgreSQL instances (postgres-14 through postgres-18) in the kind cluster and run a focused matrix test exercising the CREATE USER + GRANT + CREATE DATABASE OWNER path for each version. PG 16+ tightened GRANT defaults to NOINHERIT, NOSET, NOADMIN. A regression in the operator's admin-grant statement that omits WITH INHERIT TRUE, SET TRUE will now fail loudly on PG 16/17/18 while still passing on PG 14/15. The matrix is light — one Database CR per version, asserting Ready phase and secret presence — so it stays cheap (~1 GB RAM, ~30-60s extra CI time) while pinning behaviour across the supported version range.
Connecting as the built-in 'postgres' superuser bypasses the SET ROLE check entirely (superusers can become any role unconditionally), so the original matrix passed even on PG 16/17/18 where the bug class is supposed to bite. Bootstrap each PG instance with a non-superuser 'dbuo_admin' role (LOGIN, CREATEDB, CREATEROLE, NOSUPERUSER, NOINHERIT) via a ConfigMap-mounted /docker-entrypoint-initdb.d/init.sql. Repoint the per-version connection-string Secrets at this admin. This mirrors managed-PG providers (Scaleway managed RDB, self-hosted PG 16+ without RDS-style event triggers) where the admin is not a superuser, so the operator's GRANT path is actually exercised.
…tBackend shape PR #135 merged to main while this PR was open, replacing spec.connectionStringSecretRef + bare spec.secretName with spec.connectionString.kubernetes + spec.secretBackend.aws.
59e8d41 to
3baa411
Compare
The WITH INHERIT/SET options on GRANT are PG 16+ syntax. PR #135 emitted them unconditionally, which broke the operator on PG 14 and 15 with 'syntax error at or near INHERIT' (42601), surfaced by the new PG version matrix. Detect server_version_num via current_setting() and only append WITH INHERIT TRUE, SET TRUE on PG 16+. Pre-16 the default GRANT is sufficient — bare role membership has always implied SET ROLE on those versions, so CREATE/ALTER DATABASE OWNER works.
NOINHERIT prevented the admin from inheriting newuser's ownership privileges, so COMMENT ON DATABASE and DROP DATABASE failed with 'must be owner of database' (42501) on every PG version after the operator transferred ownership to the new user. Real managed-PG providers (AWS rds_superuser, Scaleway _rdb_superadmin, Aurora) all use INHERIT admin roles, so this mirrors production more accurately and unblocks the matrix while still keeping the admin non-superuser.
argoyle
approved these changes
May 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a per-version PostgreSQL compatibility test matrix to the integration suite. Five versioned PG instances (14, 15, 16, 17, 18) run side-by-side in the kind cluster; a single Ginkgo test exercises CREATE USER + GRANT + CREATE DATABASE OWNER against each.
Why
Smoke testing during the secrets-backend refactor (PR #135) surfaced two PG-version-specific bugs in the operator's admin-grant path:
GRANT %s TO CURRENT_USERrejected as a special role specifier on Scaleway managed RDB.CREATE DATABASE x OWNER yrequires the executor to hold SET ony. Vanilla PG 16/17/18 fail withmust be able to SET ROLE(42501) withoutWITH INHERIT TRUE, SET TRUEon the GRANT.Neither bug reproduces on AWS RDS or Aurora because their event triggers paper over PG 16's stricter defaults. We had no CI signal for vanilla / Scaleway-style providers across the supported version range. This PR closes that gap.
Files
test/integration/manifests/postgres-versions.yaml— Deployments + Services forpostgres-14...postgres-18in thedatabasesnamespace, plus admin-DSN Secrets in thedefaultnamespace.test/integration/postgres_versions_test.go— table-driven Ginkgo Describe iterating the five versions, asserting Ready phase and Secrets Manager content per version.test/integration/scripts/setup-cluster.sh— apply the new manifest and wait for all five pods.Expected CI behaviour
This branch deliberately runs against
mainwithout the PR #135 grant fix. The matrix should:GRANT %s TO CURRENT_USERstatement.Once #135 lands on main and this branch is rebased, all five versions will pass. The failure here is the point — it proves the matrix actually catches the regression class that #135 fixes, rather than being a passing rubber stamp.
Cost
Test plan